package com.itcast.article;

import com.itcast.article.po.Comment;
import com.itcast.article.service.CommentService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.test.context.junit4.SpringRunner;

import java.time.LocalDateTime;
import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class test22 {

    @Autowired
    private CommentService commentService;

    /**
     * 查询全部
     */
    @Test
    public  void test1(){
        List<Comment> commentList = commentService.findCommentList();
        System.out.println(commentList);
    }

    /**
     * 查询单个
     */
    @Test
    public  void test2(){
        Comment commentById = commentService.findCommentById("63ce6484ecafab08aadae4c6");
        System.out.println(commentById);
    }

    /**
     * 保存功能
     */
    @Test
    public  void test3(){
        Comment comment = new Comment();
        comment.setId("63ce6fdf07f7d4343c88de5e");
        comment.setArticleid("1231414");
        comment.setContent("罗纳尔多");
        comment.setCreatedatetime(LocalDateTime.now());
        comment.setLikenum(20);
        comment.setNickname("sssss");
        comment.setParentid("123141");
        comment.setPublishtime(LocalDateTime.now());
        comment.setReplynum(1);
        comment.setState("2");
        comment.setUserid("121341");
        commentService.saveComment(comment);
    }

    /**
     * 分页查询
     */
    @Test
    public  void test4(){
        Page<Comment> commentListByParentid = commentService.findCommentListByParentid("123", 1, 10);
        List<Comment> content = commentListByParentid.getContent();
        System.out.println(content);
    }


    /**
     * 点赞加一
     */
    @Test
    public  void test5(){
       commentService.updateCommentLikenum("63ce6484ecafab08aadae4c6");
    }
}
